import Common from '../../common/common.js';
let common = new Common;
Page({
  data: {
    videoSrc: '',
    type: 0,
    imgUrl: common.imgUrl
  },
  onLoad: function(options) {
    this.setData({
      type: options.type || 0,
      orgSeq: options.orgSeq || '',
      userId: options.userId || '',
      videoSrc:wx.getStorageSync('videoUrl')
    })
    this.getInfo();
  },
  gotoWxapp() {
    let path = 'pages/shop/index?orgSeq=' + this.data.orgSeq + '&userId=' + this.data.userId
    console.log('path',path);
    wx.navigateToMiniProgram({
      appId: 'wx5bf7ee148239ec22',
      path: path,
      envVersion: 'release',
      success: res => {
        console.log(res)
      },
      fail: fail => {
        console.log(fail)
      },
      complete: com => {
        console.log(com)
      }
    })
  },
  getInfo: function(e) {
    let data = {
      userId: this.data.userId,
      orgSeq: this.data.orgSeq
    }
    common.requestAjax('/api/user-service/v1/foreign/getUserAndStoreInfo', 'GET', data).then(res => {
      console.log(res)
      this.setData({
        orgName: res.data.storeInfoDTO.storeName,
        stroeInfo: res.data.storeInfoDTO,
        userInfo: res.data.userInfoDTO,
      })
      wx.setNavigationBarTitle({
        title: this.data.orgName,
      })
      //获取小程序码
      this.getWxCode();
    }).catch(err => {
      console.log(err);
    })
  },
  getWxCode() {
    let data = {
      page: "pages/shop/index",
      sceneStr: this.data.userInfo.tel + '-' + this.data.stroeInfo.authCode,
      appid: "wx5bf7ee148239ec22",
      secret: "0ca508f6771c7ca574d4a42c07874351",
      width: 300,
    }
    common.requestAjax('/api/file-service/v1/share/appletCode', 'POST', data).then(res => {
      if (res.data.code) {
        this.setData({
          wxCode: res.data.url
        })
      }
    }).catch(err => {
      console.log(err);
    })
  },
  // onShareAppMessage(res) {
  //   let authCode = ''; //门店识别标志
  //   let phone = ''; //分享人身份识别标志
  //   let path = 'pages/userShareInto/userShareInto';
  //   let params = {};
  //   let orgSeq = getApp().globalData.shopInfo.orgSeq;
  //   let userId = getApp().globalData.userId;
  //   let imageUrl = ''; //图片链接
  //   let type = this.data.currect; //分享类型 1分享店铺 2分享名片 3分享视频

  //   if (res.from === 'button') {
  //     path = path + '?orgSeq=' + orgSeq + '&userId=' + userId + '&type=' + type
  //     if (type == 1) {
  //       imageUrl = ""
  //     } else if (type == 2) {
  //       imageUrl = ""
  //     }
  //   }

  //   // 来自页面内转发按钮
  //   params = {
  //     title: getApp().globalData.shopInfo.orgName,
  //     imageUrl: imageUrl,
  //     path: path
  //   }
  //   return params
  // }
})